// pages/fuelcharging/fuelcharging.js
var that,
  api = new (require('../../utils/api.js')),
  headimg = api.getimgurl(),
  app = getApp(),
  qrcode = require('../../utils/qrcode.js'),
  util = new (require('../../utils/util.js'));
Page({

  /**
   * 页面的初始数据
   */
  data: {
    paymethod: 'wxpayment',
    ispay: !1,
    carPlate:'',
    carnum:'',
    isnooilpay: !1,
    iswashpay: !1,
    isshow: !0,
    iscon: !1,
    isSuperVip:!1,
    isFocus: false, //控制input 聚焦
    iserr: !1,
    isenough: !1,
    OilGunList: [],
    isopen: !0,
    price: '',
    choosenum: 0,
    chooseid: 0,
    inputFocus: false,
    logininfo: '',
    OilGunList: [],
    stationname: '',
    navsel: '1',
    hascarnum:!1,
    plate: '京',
    platearr: ["京", "津", "沪", "渝", "蒙", "新", "藏", "宁", "桂", "黑", "吉", "辽", "晋", "翼", "青", "鲁", "豫", "苏", "皖", "浙", "闽", "赣", "湘", "鄂", "粤", "琼", "甘", "陕", "贵", "云", "川", "0",],
    isplate: !1,
    platenum: '',
    inputFocusplatenum: !1,
    washcatelist: [],
    washmycardlist: [],
    washcatedata: "",
    balance: 0,
    last: '', isshowhis: !1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    that = this;
   
    console.log(superinfo,'superinfosuperinfo');

   

  },

  getstationinfo(){

  },

  systemstation(data){
    console.log(data,'systemstation--datadatadata');
    api.systemstation(data,res1=>{
      wx.hideLoading()
      if(res1.data.code==0){
        if(res1.data.entity.data.length>0){
          let data1 = res1.data.entity.data;
          that.setData({stationname:data1[0].name,stationId:data1[0].id})
          api.oildevice(data1[0].id, res => {
            if (res.data.code == 0) {
              if (res.data.entity) {
                that.setData({
                  OilGunList: res.data.entity.data
                })
              }
            }
          })


        }
        // let refulinglist=[],distanceid=0
        // if(res1.data.entity.data.length>0){
        //   res1.data.entity.data.forEach(x=>{
        //     if(parseInt(x.distance)<80){
        //       distanceid=x.id
        //     }
        //     if(parseInt(x.distance)>1000){
        //       x.distance=(x.distance/1000).toFixed(2)+'km'
        //     }else{
        //       x.distance=x.distance+'m'
        //     }
        //     refulinglist.push(x)
        //   })
        // let refulinglist=res1.data.entity.data
        // refulinglist.forEach(x=>{
        //   if(parseInt(x.distance)>1000){
        //     x.distance=(x.distance/1000).toFixed(2)+'km'
        //   }else{
        //     x.distance=x.distance+'m'
        //   }
        // })
        // that.setData({refulinglist})
      }else{
        wx.showModal({
          content:res1.data.message,
          showCancel:!1,
          success(){
            wx.navigateBack()
          }
        })
      }
    })
  },


  getdata() {



      let data={}
      wx.getLocation({
        success: res => {
          console.log(res,'rwesres');
          wx.showLoading({
            title: '加载中',
          })
          that.setData({lng:res.longitude,lat:res.latitude})
          data={lng:res.longitude,lat:res.latitude}
          that.systemstation(data)
        },
        fail:res=>{
          data={lng:'',lat:''}
          that.getlist()
          wx.getSetting({
            success:res=>{
              if (typeof(res.authSetting['scope.userLocation']) != 'undefined' && !res.authSetting['scope.userLocation']) {
      
                wx.showModal({
                  content: '加油站需要获取地址位置权限，是否前往开启',
                  confirmText:'前往开启',
                  success:res=>{
                    if(res.confirm){
                      wx.openSetting({
                        success: res => {
                          if (res.authSetting['scope.userLocation']) {
                            // 授权成功，重新定位
                            wx.getLocation({
                              success: res => {
                                that.setData({lat:res.latitude,lng:res.longitude})
                                data={lng:res.longitude,lat:res.latitude}
                                that.systemstation(data)
                              },fail:res=>{
                                data={lng:'',lat:''}
                                that.systemstation(data)
                              }
                            });
                          } else {
                            // 没有允许定位权限
                            data={lng:'',lat:''}
                            that.systemstation(data)
                          }
                        },fail:res=>{
                          data={lng:'',lat:''}
                          that.systemstation(data)
                        }
                      });
                    }else{
                      data={lng:'',lat:''}
                      that.systemstation(data)
                    }
                  },fail:res=>{
                    data={lng:'',lat:''}
                    that.systemstation(data)
                  }
                })
              }else{
                 wx.getLocation({
                       success:res=>{
                        that.setData({lat:res.latitude,lng:res.longitude})
                        data={lat:res.latitude,lng:res.longitude}
                        that.systemstation(data)
                       }
                   })
              }
            },fail:res=>{
              data={lng:'',lat:''}
              that.systemstation(data)
            }
          }) 
        }
      })
    let {
      stationId
    } = that.data
    console.log(stationId, 'stationIdstationIdstationId');

  

    let { corpGoodsTag, corpWashTag ,msgTplIdArr} = app.logininfo
    that.setData({ corpGoodsTag, corpWashTag ,msgTplIdArr})
    api.washcate(stationId, res => {
      if (res.data.code == 0) {
        if (res.data.entity) {
          let washcatedata = res.data.entity.data.infoArr[0]
          that.setData({ washcatelist: res.data.entity.data, washcatedata, washcateid: washcatedata.id })
        }
      }
    })
    that.washmycard()
  },
  washmycard() {
    let {
      stationId
    } = that.data, historycarnum = []
    api.washmycard(stationId, res => {
      if (res.data.code == 0) {
        if (res.data.entity) {
          let washmycardlist = res.data.entity.data
          washmycardlist.infoArr.forEach(x => {
            x.payTime = util.toDate1(x.payTime)
            x.validTime = util.toDate1(x.validTime)
          })
          that.setData({
            washmycardlist
          })
        }
      }
    })
    let history = wx.getStorageSync('historycarnum')
    if (history) {
      historycarnum = history
    }
    that.setData({ historycarnum })
  },
  clickinput() {
    console.log(that.data.inputFocus, 'inputFocusinputFocus');

    that.setData({
      inputFocus: !0,
      isshow: !1
    })
  },
  inputvalue(e) {
    that.setData({ last: e.detail.value })
  },
  clickinputplatenum() {
    let {
      plate
    } = that.data
    if (plate != '0') {
      that.setData({
        inputFocusplatenum: !0, isshowhis: !0
      })
    }
  },
  clickislastFocus() {
    that.setData({
      islastFocus: !0
    })
  },
  bindblur() {
    that.setData({
      isshow: !0,
      inputFocus: !1,
      inputFocusplatenum: !1,
      islastFocus: !1
    })
  },
  inputtap(e) {
    let {
      value
    } = e.detail
    that.setData({
      price: value
    })
  },
  inputtapplatenum(e) {
    let {
      value
    } = e.detail
    that.setData({
      platenum: value.toUpperCase()
    })
  },
  open() {
    let {
      isopen
    } = that.data
    that.setData({
      isopen: !isopen
    })
  },
  selnum(e) {
    let { item } = e.currentTarget.dataset, { last } = that.data
    that.setData({ last: item.last, platenum: item.platenum, plate: item.plate, isshowhis: !1 })
  },
  tochoose(e) {
    let {
      num
    } = e.currentTarget.dataset, {
      OilGunList,
      choosenum,
      chooseid
    } = that.data
    OilGunList.forEach(x => {
      if (x.id == num) {
        choosenum = parseInt(x.name)
        chooseid = x.id
      }
    })
    that.setData({
      choosenum,
      chooseid
    })
  },
  //确认加油
  confirmRefueling() {
    let {
      choosenum,
      price,
      chooseid
    } = that.data, err = ''
    if (price <= 0 || price == '') err = "请输入金额"
    if (chooseid == 0) err = "请选择油枪"
    if (err != '') {
      wx.showModal({
        content: err,
        showCancel: !1,
      })
      return;
    }
    wx.showLoading({
      title: '加载中',
    })
    api.oilplace({
      oilFee: price,
      fromId:1,
      did: chooseid
    }, res => {
      wx.hideLoading()
      if (res.data.code == 0) {
        let {
          couponFee,
          levelName,
          litPic,
          name,
          needPay,
          orderId,
          oilName,
          hasPayPwd
        } = res.data.entity.data

        that.setData({
          ispay: !0,
          isshow: !1,
          couponFee,
          levelName,
          litPic,
          name,
          needPay,
          orderId,
          oilName,
          hasPayPwd
        })

      }
    })
  },
  // 非油品 确认加油
  confirmRefueling1() {
    let {
      stationId,
      price
    } = that.data, err = ''
    if (price <= 0 || price == '') err = "请输入金额"
    // if(chooseid==0)err="请选择油枪"
    if (err != '') {
      wx.showModal({
        content: err,
        showCancel: !1,
      })
      return;
    }
    wx.showLoading({
      title: '加载中',
    })
    api.goodsplace({
      fee: price,
      stationId
    }, res => {
      wx.hideLoading()
      if (res.data.code == 0) {
        let {
          couponFee,
          levelName,
          litPic,
          name,
          needPay,
          orderId,
          oilName,
          hasPayPwd
        } = res.data.entity.data

        that.setData({
          isnooilpay: !0,
          isshow: !1,
          couponFee,
          levelName,
          litPic,
          name,
          needPay,
          orderId,
          oilName,
          hasPayPwd
        })

      }
    })
  },
  //非油品 支付
  toconfirm1() {
    let { paymethod, orderId, hasPayPwd, navsel } = that.data
    if (paymethod == 'bapaymen') { //余额支付
      if (hasPayPwd == 0) {
        that.setData({
          isenough: !0,
          isshow: !1,
          isFocus: !1,
          iscon: !1
        })
      } else {
        that.setData({
          iscon: !0,
          ispay: !1,
          isFocus: true,
          wallets_password: '',
          isnooilpay: !1, balance: 1,
        })
      }
    } else { //微信支付
      wx.showLoading({
        title: '加载中',
      })
      api.systemcorpinfo(res => {
        if (res.data.code == 0) {
          if (res.data.entity.data.corpExpired == 1) {
            wx.hideLoading()
            wx.showModal({
              title: '提示',
              content: '系统已过期，无法充值',
              showCancel: !1,
            })
            return;
          } else {
            api.nooilprepay({
              orderId
            }, res => {
              wx.hideLoading()
              console.log(res, 'res');
              if (res.succ == 1) {
                wx.navigateTo({
                  url: '../orderpaysucc/orderpaysucc?orderId=' + orderId + '&code=' + navsel,
                })
              } else {
                wx.showModal({
                  content: res.msg,
                  showCancel: !1,
                })
              }
            })
          }
        } else {
          wx.hideLoading()
          wx.showToast({
            title: res.data.message,
            icon: 'none'
          })
        }
      })
    }
  },

  addplatenum(){
    let { platenum,plate,last} = that.data,err = ''
    if (platenum .length < 6) err = "请输入完整的牌号"
    if (err != '') {
      wx.showModal({
        content: err,
        showCancel: !1,
      })
      return;
    }
    wx.showLoading({
      title: '加载中',
    })
    let carPlate = ''
    if (last != '') {
      platenum = platenum + last
    }
    if (plate == '0') {
      carPlate = platenum
    } else {
      carPlate = plate + platenum
    }
   // console.log(carPlate,'carPlate');
    api.用户绑定超会车牌(carPlate,res=>{
      if(res.data.code==0){
        wx.showModal({
          title: '提示',
          content: '绑定成功',
          showCancel:!1,
          complete: (res) => {
            if (res.confirm) {
             that.getcarplate()
            }
          }
        })
      }
    })
  },

  // 洗车
  confirmRefueling2() {
    // wx.navigateTo({
    //   url: `../buysucc/buysucc`,
    // })
    let { platenum, washcateid, stationId, plate, last } = that.data, err = '', oldplatenum = platenum
    if (plate != '0' && platenum.length < 6) err = "请输入完整的牌号"
    if (platenum == '') err = "请输入牌号"
    if (err != '') {
      wx.showModal({
        content: err,
        showCancel: !1,
      })
      return;
    }
    wx.showLoading({
      title: '加载中',
    })
    if (last != '') {

      platenum = platenum + last
    }
    let carPlate = ''
    if (plate == '0') {
      carPlate = platenum
    } else {
      carPlate = plate + platenum
    }
    api.washplace({ cateId: washcateid, carPlate, stationId }, res => {
      wx.hideLoading()
      if (res.data.code == 0) {
        if (plate != '0') {
          let history = wx.getStorageSync('historycarnum')
          if (history.length < 3) {
            let data = { platenum: oldplatenum, plate: plate, last: last }, list = []
            list.push(data)
            if (history.length > 0) {
              history.forEach(x => {
                if (x.platenum == oldplatenum && x.plate == plate && x.last == last) {
                  return
                } else {
                  let newlist = list.concat(history)
                  wx.setStorageSync('historycarnum', newlist)
                }
              })

            } else {
              let newlist = list
              wx.setStorageSync('historycarnum', newlist)
            }
          } else {
            let history = wx.getStorageSync('historycarnum'), list = []
            history.splice(0, 1)
            let data = { platenum: oldplatenum, plate: plate, last: last }
            list.push(data)
            let newlist = list.concat(history)
            wx.setStorageSync('historycarnum', newlist)
          }
        }
        let { couponFee, levelName, litPic, name, needPay, orderId, oilName, hasPayPwd } = res.data.entity.data
        that.setData({ iswashpay: !0, isshow: !1, couponFee, levelName, litPic, name, needPay, orderId, oilName, hasPayPwd })
      }
    })
  },

  vipwash(){
    let{washcatelist,carPlate,stationId} =  this.data,{infoArr} = washcatelist,cateId=infoArr[0].id
    api.用户提交洗车订单({stationId,carPlate,cateId},res=>{
      if(res.data.code==0){
        let  orderId = res.data.entity.data.orderId
        api.超会免费洗车订单(orderId,res1=>{
          wx.hideLoading()
          console.log(res, 'res');
          // if (res.succ == 1) {
          
          //   // wx.navigateTo({
          //   //   url: '../orderpaysucc/orderpaysucc?orderId=' + orderId + '&code=' + navsel,
          //   // })
          // } else {
          //   wx.showModal({
          //     content: res.msg,
          //     showCancel: !1,
          //   })
          // }



          if(res1.data.code==0){
              wx.showModal({
                title: '提示',
                content: '提交成功',
                showCancel:!1,
                complete: (res) => {
                  if (res.confirm) {
                    wx.navigateTo({
                      url: `../buysucc/buysucc?orderId=${orderId}&super=1`,
                    })
                  }
                }
              })
          }else{
            wx.showModal({
              title: '提示',
              content: res.data.msg,
              showCancel:!1,
              complete: (res) => {
                if (res.confirm) {
                }
              }
            })
          }
        })
      }else{
        console.log(12345,res.data.message);
        wx.showModal({
          title: '提示',
          content: res.data.message,
                                                                 showCancel:!1,
          complete: (res) => {
            if (res.confirm) {
            }
          }
        })
      }
    })
  },


  //洗车 支付
  toconfirm2() {
    let { paymethod, orderId, hasPayPwd, navsel, needPay } = that.data
    if (paymethod == 'bapaymen') { //余额支付
      if (hasPayPwd == 0) {
        that.setData({
          isenough: !0,
          isshow: !1,
          isFocus: !1,
          iscon: !1
        })
      } else {
        that.setData({ iscon: !0, iswashpay: !1, isFocus: true, wallets_password: '', balance: 2, })
      }
    } else { //微信支付
      wx.showLoading({
        title: '加载中',
      })
      api.systemcorpinfo(res => {
        if (res.data.code == 0) {
          if (res.data.entity.data.corpExpired == 1) {
            wx.hideLoading()
            wx.showModal({
              title: '提示',
              content: '系统已过期，无法充值',
              showCancel: !1,
            })
            return;
          } else {
            if (Number(needPay) > 0) {
              api.washprepay({
                orderId
              }, res => {
                wx.hideLoading()
                console.log(res, 'res');
                if (res.succ == 1) {
                  wx.navigateTo({
                    url: `../buysucc/buysucc?orderId=${orderId}`,
                  })
                  // wx.navigateTo({
                  //   url: '../orderpaysucc/orderpaysucc?orderId=' + orderId + '&code=' + navsel,
                  // })
                } else {
                  wx.showModal({
                    content: res.msg,
                    showCancel: !1,
                  })
                }
              })
            } else {
              let payType = 2
              api.washspecailpay({ orderId, payType }, res => {
                if (res.data.code == 0) {
                  wx.navigateTo({
                    url: `../buysucc/buysucc?orderId=${orderId}`,
                  })
                }else {
                  wx.showModal({
                    content: res.msg,
                    showCancel: !1,
                  })
                }
              })
            }
          }
        } else {
          wx.hideLoading()
          wx.showToast({
            title: res.data.message,
            icon: 'none'
          })
        }
      })
    }
  },
  inputFn: function (e) {
    return e.detail.value.toUpperCase()
  },
  close() {
    that.setData({
      ispay: !1,
      isshow: !0,
      isnooilpay: !1, iswashpay: !1,
    })
  },
  tochoosepay(e) {
    let {
      way
    } = e.currentTarget.dataset, {
      paymethod
    } = that.data
    if (way == paymethod) {
      return
    }
    that.setData({
      paymethod: way
    })
  },
  set_wallets_password(e) { //获取钱包密码，余额支付
    // console.log(e,'eeeeeeeeeeeee');
    let {
      orderId,
      navsel, balance, needPay
    } = that.data
    this.setData({
      wallets_password: e.detail.value
    });
    if (this.data.wallets_password.length == 6) { //密码长度6位时，自动验证钱包支付结果
      let pwd = e.detail.value
      if (balance == 0) {//油品余额支付
        api.ordercheckaccountpay({
          orderId,
          pwd
        }, res => {
          if (res.data.code == 0) {
            that.setData({
              isFocus: !1,
            }, () => {
              wx.navigateTo({
                url: '../orderpaysucc/orderpaysucc?orderId=' + orderId + '&code=' + navsel,
              })
            })
          } else if (res.data.code == 20312) {
            that.setData({
              iserr: !0,
              isshow: !1,
              isFocus: !1,
              iscon: !1
            })
          } else {
            that.setData({
              isenough: !0,
              isshow: !1,
              isFocus: !1,
              iscon: !1
            })
          }
        })
      } else if (balance == 1) {//非油品余额支付
        api.goodsaccountpay({
          orderId,
          pwd
        }, res => {
          if (res.data.code == 0) {
            that.setData({
              isFocus: !1,
            }, () => {
              wx.navigateTo({
                url: '../orderpaysucc/orderpaysucc?orderId=' + orderId + '&code=' + navsel,
              })
            })
          } else if (res.data.code == 20312) {
            that.setData({
              iserr: !0,
              isshow: !1,
              isFocus: !1,
              iscon: !1
            })
          } else {
            that.setData({
              isenough: !0,
              isshow: !1,
              isFocus: !1,
              iscon: !1
            })
          }
        })
      } else if (balance == 2) {//洗车余额支付
        if (Number(needPay) > 0) {
          api.washaccountpay({
            orderId,
            pwd
          }, res => {
            if (res.data.code == 0) {
              that.setData({
                isFocus: !1,
              }, () => {
                wx.navigateTo({
                  url: '../buysucc/buysucc?orderId=' + orderId,
                })
              })
            } else if (res.data.code == 20312) {
              that.setData({
                iserr: !0,
                isshow: !1,
                isFocus: !1,
                iscon: !1
              })
            } else {
              that.setData({
                isenough: !0,
                isshow: !1,
                isFocus: !1,
                iscon: !1
              })
            }
          })
        } else {
          let payType = 1
          api.washspecailpay({ orderId, payType }, res => {
            if (res.data.code == 0) {
              wx.navigateTo({
                url: `../buysucc/buysucc?orderId=${orderId}`,
              })
            } else if (res.data.code == 20312) {
              that.setData({
                iserr: !0,
                isshow: !1,
                isFocus: !1,
                iscon: !1
              })
            } else {
              that.setData({
                isenough: !0,
                isshow: !1,
                isFocus: !1,
                iscon: !1
              })
            }
          })
        }
      }
    }
  },
  close_wallets_password() {
    that.setData({
      iscon: !1,
      isshow: !0
    })
  },
  set_Focus() { //聚焦input
    console.log('isFocus', this.data.isFocus)
    this.setData({
      isFocus: true
    })
  },

  toconfirm() {
    let { paymethod, orderId, hasPayPwd, navsel, msgTplIdArr } = that.data, newmsgTplIdArr = []
    newmsgTplIdArr.push(msgTplIdArr.couponGain, msgTplIdArr.couponOverdue, msgTplIdArr.scoreChange)
    wx.requestSubscribeMessage({
      tmplIds: newmsgTplIdArr,
      success: function (res) {
        console.log(res, 'eeeeeeee')
        if (paymethod == 'bapaymen') { //余额支付
          if (hasPayPwd == 0) {
            that.setData({
              isenough: !0,
              isshow: !1,
              isFocus: !1,
              iscon: !1
            })
          } else {
            that.setData({
              iscon: !0,
              ispay: !1,
              isFocus: true,
              wallets_password: '',
              isnooilpay: !1,
              iswashpay: !1,
            })
          }
        } else { //微信支付
          wx.showLoading({
            title: '加载中',
          })
          api.systemcorpinfo(res => {
            if (res.data.code == 0) {
              if (res.data.entity.data.corpExpired == 1) {
                wx.hideLoading()
                wx.showModal({
                  title: '提示',
                  content: '系统已过期，无法充值',
                  showCancel: !1,
                })
                return;
              } else {
                api.prepay({
                  orderId
                }, res => {
                  wx.hideLoading()
                  console.log(res, 'res');
                  if (res.succ == 1) {
                    wx.navigateTo({
                      url: '../orderpaysucc/orderpaysucc?orderId=' + orderId + '&code=' + navsel,
                    })
                  } else {
                    wx.showModal({
                      content: res.msg,
                      showCancel: !1,
                    })
                  }
                })
              }
            } else {
              wx.hideLoading()
              wx.showToast({
                title: res.data.message,
                icon: 'none'
              })
            }
          })
        }
      },
      fail: function (err) {
        console.log(err, 'rrrrrrrrr')
        if (paymethod == 'bapaymen') { //余额支付
          if (hasPayPwd == 0) {
            that.setData({
              isenough: !0,
              isshow: !1,
              isFocus: !1,
              iscon: !1
            })
          } else {
            that.setData({
              iscon: !0,
              ispay: !1,
              isFocus: true,
              wallets_password: '',
              isnooilpay: !1,
              iswashpay: !1,
            })
          }
        } else { //微信支付
          wx.showLoading({
            title: '加载中',
          })
          api.systemcorpinfo(res => {
            if (res.data.code == 0) {
              if (res.data.entity.data.corpExpired == 1) {
                wx.hideLoading()
                wx.showModal({
                  title: '提示',
                  content: '系统已过期，无法充值',
                  showCancel: !1,
                })
                return;
              } else {
                api.prepay({
                  orderId
                }, res => {
                  wx.hideLoading()
                  console.log(res, 'res');
                  if (res.succ == 1) {
                    wx.navigateTo({
                      url: '../orderpaysucc/orderpaysucc?orderId=' + orderId + '&code=' + navsel,
                    })
                  } else {
                    wx.showModal({
                      content: res.msg,
                      showCancel: !1,
                    })
                  }
                })
              }
            } else {
              wx.hideLoading()
              wx.showToast({
                title: res.data.message,
                icon: 'none'
              })
            }
          })
        }
      }
    })

  },

  modify_password() {
    that.setData({
      iserr: !1,
      iscon: !1
    }, () => {
      wx.navigateTo({
        url: '../forgetPwd/forgetPwd',
      })
    })
  },
  retry() {
    that.setData({
      iserr: !1,
      iscon: !0,
      wallets_password: '',
      isFocus: !0,
      wallets_password: ''
    })
  },
  closeerr() {
    that.setData({
      iserr: !1,
      iscon: !1,
      isshow: !0,
      isplate: !1
    })
  },
  torecharge() {
    wx.navigateTo({
      url: '../recharge/recharge',
    })
  },
  closebu() {
    that.setData({
      isenough: !1,
      isshow: !0,
      wallets_password: ''
    })
  },
  navsel(e) {
    let {
      code
    } = e.currentTarget.dataset
    console.log(code, 'codecode');
    if(code==2){
      api.超会月礼品领取(res=>{
          if(res.data.code==0){
            wx.getSystemInfo({
              success: (res_sys) => {
                new qrcode({
                  width: res_sys.screenWidth * 0.68,
                  height: res_sys.screenWidth * 0.68,
                  canvasId: 'canvas',
                  text:res.data.entity.data.qrCode,
                  callback: res => {
                    wx.hideLoading();
                    //that.getisDeal()
                  }
                })
              },
            })
          }
       


      })
    }
    if(code=='3'){
      that.getcarplate()
     
    }
    that.setData({
      navsel: code,
      price: '',
      paymethod: 'wxpayment'
    })
  },

  getcarplate(){
    api.得到超会车牌信息(res=>{
      if(res.data.code==0){
        let{carPlate} = res.data.entity.data
        if(carPlate!=null){
          api.washcate(that.data.stationId, res_washcate => {
            wx.hideLoading()
            if (res_washcate.data.code == 0) {
              if (res_washcate.data.entity) {
                let washcatedata = res_washcate.data.entity.data.infoArr[0]
                that.setData({carPlate, washcatelist: res_washcate.data.entity.data, washcatedata, washcateid: washcatedata.id })
              }
            }
          })
        }
        that.setData({carPlate})
        
       // that.setData({})

      }
  })

  },

  platesel() {
    that.setData({
      isplate: !0
    })
  },
  plate(e) {
    let {
      item
    } = e.currentTarget.dataset, {
      plate
    } = that.data
    if (plate == item) {
      return;
    } else {
      if (item == '0') {
        that.setData({
          platenum: '临时号牌'
        })
      } else {
        that.setData({
          platenum: ''
        })
      }
    }

    that.setData({
      plate: item,
      isplate: !1
    })
  },
  //切换洗车类型
  intensivebtn(e) {
    let { id } = e.currentTarget.dataset, { washcatelist } = that.data
    washcatelist.infoArr.forEach(x => {
      if (x.id == id) {
        that.setData({ washcatedata: x, washcateid: x.id })
      }
    })
  },
  to(e) {
    let { url, brief } = e.currentTarget.dataset
    wx.navigateTo({
      url: `../${url}/${url}?brief=${brief}`,
    })
  },
  closeishowhis() {
    that.setData({ isshowhis: !1 })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let car = wx.getStorageSync('carnav')
    if(car=="1"){
        this.setData({navsel:3,ispay:!1})
        that.getcarplate()
        wx.removeStorageSync('carnav')
    }

    let superinfo = wx.getStorageSync('superinfo')
    that.setData({isSuper:superinfo.isSuper})
    if(superinfo.isSuper!=1){
      wx.showModal({
        title: '提示',
        content: '暂未开通此功能',
        showCancel:!1,
        complete: (res) => {
          if (res.confirm) {
              wx.switchTab({
                url: '../index/index',
              })
          }
        }
      })
    }else{
      let logininfo = app.logininfo,
      stationname = '',
      page = getCurrentPages();
    page = page[page.length - 2];
    console.log(page, 'pagepagepage');
    let userInfo = wx.getStorageSync('userInfo') 
    that.setData({
      logininfo,
      stationname, userInfo
    }, () => {
      that.getdata()
    })
    }

    // that.setData({
    //   iscon: !1,
    //   isshow: !0,
    //   wallets_password: '',
    //   ispay: !1,
    //   iserr: !1,
    //   isenough: !1,
    //   isnooilpay: !1,
    //   iswashpay: !1,
    //   isshowhis: !1
    // })
    // that.washmycard()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})